﻿using System;
using Mono.Cecil;
using OpenReflect.Domain.Contracts;
using OpenReflect.Domain.Contracts.Declarations;
using OpenReflect.Domain.Model;

namespace OpenReflect.Services.Builders
{
	public interface ITypeDeclarationBuilder
	{
		//IList<IParameter> CreateParameters(MethodDefinition definition);
		ITypeDeclaration CreateTypeDeclaration(TypeDefinition definition);
	}
	public interface ITypeDeclarationBuilder<T> : ITypeDeclarationBuilder where T : ITypeDeclaration
	{
		//IList<IParameter> CreateParameters(MethodDefinition definition);
		T CreateTypeDeclaration(TypeDefinition definition);
	}
	public class TypeDeclarationBuilder : ITypeDeclarationBuilder
	{
		#region ITypeDeclarationBuilder Members

		public ITypeDeclaration CreateTypeDeclaration(TypeDefinition definition)
		{
			ITypeDeclarationBuilder builder;
			if(definition.IsClass)
				builder = new ClassDeclarationBuilder();
			else
				throw new NotImplementedException();
			ITypeDeclaration retVal = builder.CreateTypeDeclaration(definition);
			//definition.I
			//Cecil.FlowAnalysis.ActionFlow.ActionFlowGraph g = new Cecil.FlowAnalysis.ControlFlow.ControlFlowGraph();g.

			return retVal;
		}

		#endregion

		//public IParameter CreateParameter(ParameterDefinition definition)
		//{
		//    IParameter retVal = new Parameter();
		//    retVal.Name = definition.Name;

		//    return retVal;
		//}
	}
}